/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import conf.HibernateUtil;
import doa.HibernateSessionController;
import java.util.List;
import models.Message;
import models.Twitterer;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 *
 * @author Misja
 */
public class CreateRetrieveMessage {

    public CreateRetrieveMessage() {
    }

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }
    // TODO add test methods here.
    // The methods must be annotated with annotation @Test. For example:
    //
    // @Test
    // public void hello() {}

    @Test
    public void createRetrieveTwitterer() {
        

        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();

        try {
              Query query = HibernateSessionController.Instance().getHibernateSession().createQuery("select count(*) from Message ");
            int count = (Integer)query.uniqueResult();
            System.out.println("count");
            session.getTransaction().commit();
        } catch (HibernateException e) {
            System.out.println("HibernateFout: " + e);
            session.close();
            assert false;
        }

        assert true;
    }
}